home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / ISSUE20 / CLINIC / RAMU.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1997-01-29  |  2.0 KB  |  76 lines

  1. unit RAMU;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   StdCtrls;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     Label1: TLabel;
  12.     Label2: TLabel;
  13.     procedure FormCreate(Sender: TObject);
  14.   private
  15.     { Private declarations }
  16.   public
  17.     { Public declarations }
  18.   end;
  19.  
  20. var
  21.   Form1: TForm1;
  22.  
  23. implementation
  24.  
  25. {$R *.DFM}
  26.  
  27. uses
  28.   QTThunkU;
  29.  
  30. var
  31.   DLLHandle: THandle16;
  32.  
  33. const
  34.   //To access a CMOS data value, write its address
  35.   //into port $70 and read its value from port $71
  36.   CMOSSelector = $70;
  37.   CMOSData = $71;
  38.   BaseMemLo = $15;
  39.   BaseMemHi = $16;
  40.   ExtMemLo = $17;
  41.   ExtMemHi = $18;
  42.  
  43. procedure TForm1.FormCreate(Sender: TObject);
  44. var
  45.   BaseRAMAmount, ExtRAMAmount: Word;
  46. begin
  47.   Call16BitRoutine('WritePort', DllHandle, ccPascal,
  48.     [CMOSSelector, BaseMemLo], [SizeOf(Word), SizeOf(Byte)]);
  49.   WordRec(BaseRAMAmount).Lo := Call16BitRoutine('ReadPort',
  50.     DllHandle, ccPascal, [CMosData], [SizeOf(Byte)]);
  51.   Call16BitRoutine('WritePort', DllHandle, ccPascal,
  52.     [CMOSSelector, BaseMemHi], [SizeOf(Word), SizeOf(Byte)]);
  53.   WordRec(BaseRAMAmount).Hi := Call16BitRoutine('ReadPort',
  54.     DllHandle, ccPascal, [CMosData], [SizeOf(Byte)]);
  55.  
  56.   Call16BitRoutine('WritePort', DllHandle, ccPascal,
  57.     [CMOSSelector, ExtMemLo], [SizeOf(Word), SizeOf(Byte)]);
  58.   WordRec(ExtRAMAmount).Lo := Call16BitRoutine('ReadPort',
  59.     DllHandle, ccPascal, [CMosData], [SizeOf(Byte)]);
  60.   Call16BitRoutine('WritePort', DllHandle, ccPascal,
  61.     [CMOSSelector, ExtMemHi], [SizeOf(Word), SizeOf(Byte)]);
  62.   WordRec(ExtRAMAmount).Hi := Call16BitRoutine('ReadPort',
  63.     DllHandle, ccPascal, [CMosData], [SizeOf(Byte)]);
  64.  
  65.   Label2.Caption := Format('%dkb base, %.0nkb extended',
  66.     // Turn extended memory integer value into a float so we
  67.     // can use %n and get it nicely formatted with commas
  68.     [BaseRAMAmount, ExtRAMAmount * 1.0]);
  69. end;
  70.  
  71. initialization
  72.   DLLHandle := LoadLib16('Ports.DLL');
  73. finalization
  74.   FreeLibrary16(DllHandle);
  75. end.
  76.